<extend name="base/Base" />
<block name="Style">
<!-- FooTable Plugin CSS -->
<!-- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/vendor/plugins/footable/css/footable.core.min.css">
		<!-- Admin Forms CSS -->
		<link rel="stylesheet" type="text/css" href="__ABSOLUTEADMIN__/assets/admin-tools/admin-forms/css/admin-forms.css">
		<js href="__ADDON__/ajaxupload/js/jquery.js" />
		
		<js href="__ADDON__/ajaxupload/js/ajaxupload.js" />
		<script type="text/javascript" src="/public/addon/kindeditor/kindeditor.js"></script>
		<script type="text/javascript">
		$(function(){
			var button = $('#upload_button'), interval;
			var confirmdiv = $('#uploadphotoconfirm');
			var fileType = "pic",fileNum = "one"; 
			new AjaxUpload(button,{
				action: "__APP__/Home/Upload/Image/Addon/AjaxUpload.html",
				name: 'userfile',
				onSubmit : function(file, ext){
					if(fileType == "pic")
					{
						if (ext && /^(jpg|png|jpeg|gif|JPG|xls|xlsx)$/.test(ext)){
							this.setData({
								'info': '文件类型为图片'
							});
						} else {
							 confirmdiv.text('文件格式错误，请上传格式为.png .jpg .jpeg 的图片');
							return false;               
						}
					}		
					confirmdiv.text('文件上传中');
					
					if(fileNum == 'one')
						this.disable();
					
					interval = window.setInterval(function(){
						var text = confirmdiv.text();
						if (text.length < 14){
							confirmdiv.text(text + '.');                    
						} else {
							confirmdiv.text('文件上传中');             
						}
					}, 200);
				},
				onComplete: function(file, response){
					if(response != "success"){
						if(response =='2'){
							confirmdiv.text("文件格式错误，请上传格式为.png .jpg .jpeg 的图片");
						}else{
							
							confirmdiv.text("上传完成");
							
							$("#newbikephotoName").val(response);
							$("#newbikephoto").attr("src",response);	
							$("#imgurl").attr("value",response);						
							
						}
						
					}
										  
					window.clearInterval(interval);
								
					this.enable();
					
					if(response == "success")
					alert('上传成功');              
				}
			});
		});
		</script>

</block>
<block name="Topbar">
 <header id="topbar" class="ph10">
        <div class="topbar-left">
          <ul class="nav nav-list nav-list-topbar pull-left">
            
           <!--  <li   >
              <a  href="__APP__/Admin/Data/Manage.html"   >数据管理</a>
            </li> -->
			 <!-- <li>
              <a href="#"  data-toggle="modal" data-target="#myModal" >新增文件</a>
            </li> -->
			<li   class="active">
              <a  href="#"   >文件详情</a>
            </li>
          <!--  <li   >
              <a  href="__APP__/Home/Auth/Login/Addon/PHPMyAdmin.html" target="_blank"  >phpMyAdmin</a>
            </li> -->
          </ul>
        </div>
        <div class="topbar-right hidden-xs hidden-sm">
		<form name="frm" method="post" action="__APP__/Mall/Classify/zip.html" enctype="multipart/form-data" style="margin-right:20px;">					
			<span style="color:#666;font-size:13px;line-height:40px;" id="fileName"></span>
			<div title="选择文件" style="vertical-align:middle; border-radius:100%;overflow:hidden; width:auto;display:inline-block;position:relative;width:40px;height:40px;background-image:url(https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1520317374&di=08c67b180e4badcd1fd23177c159ea4c&src=http://pic.orsoon.com/2016/0511/20160511051215479.png);background-repeat:no-repeat;background-size:cover;">
				<input id="fileImg" type="file" multiple="multiple" name="image[]"  style="width:40px;height:40px;position:absolute;top:0;left:0;opacity:0;"/>
				<input type="hidden" name="form_id" value="{$form_id}"/>
				<input type="hidden" name="type" value="{$type}"/>
			</div>
			
			<input type="submit" title="点击上传" style="border-radius:100%; vertical-align:middle;height:40px;width:40px;outline:none;background-image:url(https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2350385466,732838778&fm=27&gp=0.jpg);background-repeat:no-repeat;background-size:cover;border:none;" value=''/>
		 </form>
        </div>
      </header>
</block>
<block name="Content">
	 <!-- begin: .tray-center -->
        <div class="row">

        <!-- Panel with: Data Filter -->
          <div class="col-md-12" id="spy2" >
            <div class="panel-heading">
              <span class="panel-title">
                <span class="fa fa-search"></span>数据信息</span>
				<div class="pull-right">
			 				
               <!--    <a  href="#" data-toggle="modal" data-target="#myModal" class="btn btn btn-primary">新增分类</a>						
								
							 -->	<!-- Modal -->
									<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
									  <div class="modal-dialog" role="document">
										<div class="modal-content">
										  <div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
											<h4 class="modal-title" id="myModalLabel">新增文件</h4>
										  </div>
										  <div class="modal-body">
										    <form class="form-horizontal" role="form">
					
				   <section>
						<label class="control-label" for="bike_type">&nbsp;</label>
							<input type="file" style="display:none" name="userfile">
							<input type="hidden" id="newbikephotoName" name="img" value="" />
							<input type="hidden" id="oldbikephotoName" value="" />
							<div class="controls" style="text-align:center;">
								<img  id="newbikephoto" src="http://image.zaiyoudao.com/image.php/zyd_126.html" style="max-height:200px;max-width:200px;" />
								<span class="help-inline"></span>
								<br>
								<div id="uploadphotoconfirm"></div>
								<br>
								<input type="hidden" name="img" id="imgurl" value="" style="max-height:200px;max-width:200px;"  >
								<input type="button" class="btn btn-lg btn-primary" style="width:50%" id="upload_button"  value="上传文件" /><br/>
								
							</div>
					</section>
					<br>
                </form>
										  </div>
										  <div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal">关闭页面</button>
											<a href="#" class="btn btn-primary" onclick="create()" >新增文件</a>
											
										  </div>
										</div>
									  </div>
									</div>
								<script>
								
								
								var file = $('#fileImg'),
								aim = $('#fileName');
								file.on('change', function( e ){
									//e.currentTarget.files 是一个数组，如果支持多个文件，则需要遍历
									
									var name = "";
									for(var i=0;i<e.currentTarget.files.length;i++){
										name+=e.currentTarget.files[i].name+",";
									}
									aim.text( "已选择"+name+"文件");
								});
															
								
						
							//新增分类
							function create(){  
							
								var img = $("#newbikephotoName").val();
								
								$.ajax({
									type:'POST',
									url:"__APP__/CMS/Channel/Create.html",
									data:{
										
										"adr_rpt_code": "{$adr_rpt_code}",
										"img": img,
										
									},
									success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
									},
									error:function(){
										layer.msg('系统繁忙,请稍候重试！');
									}
								
								});	 
							}  
							
							function AJAXDelete(id){  
								if(confirm('是否确认删除')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Delete.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('删除成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							
							function AJAXOutage(id){  
								if(confirm('是否确认隐藏')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Outage.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('隐藏成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							
							function AJAXEnabled(id){  
								if(confirm('是否确认显示')){
									$.ajax({
										type:'POST',
										url:"__APP__/AICMF/Menu/Value/Enabled.html",
										data:{
											"id": id,
											
										},
										success:function(data){								
											if (data == 1) {
											alert('显示成功');
											window.location.reload();
											}else{
												alert(data);
											}
										},
										error:function(){
											alert('未知错误');
										}
									
									});	 
								}
							} 
							</script>
							
              </div> 
            </div>
            <div class="panel-menu">
              <input id="fooFilter" type="text" class="form-control" placeholder="请输入搜索的关键字">
            </div>
            <div class="panel-body pn">
              <table class="table footable" data-filter="#fooFilter"  data-page-navigation=".pagination" data-page-size="100">
               <thead>
												<tr>
													
													<!-- <th style="width:4%;">批量</th>
													 --><th data-hide="phone,tablet">#</th>
													<th data-class="expand">文件名</th>
													<th data-class="expand">大小</th>
													<th data-class="expand">上传时间</th>
													<th data-class="expand">使用状态</th>
													<th data-hide="phone">操作</th>
												</tr>
											</thead>
											<tbody>
											
												<volist name="list" id="list">
												
												<tr>
													
													<td>{$i}</td>
													<td>{$list.original_name}</td>
													<td>{$list.size}</td>
													<td>{$list.time}</td>
													<td><if condition="$list.employ eq 1">使用中</if></td>
													<td>
														
														<a  href="#" class="btn btn-xs btn-success" onclick='employ({$form_id},{$type},{$list.id})'>使用</a>
														<a  href="#" class="btn btn-xs btn-success" onclick='delete_file({$list.id})'>删除</a>
														<a  href="__APP__{$list.url}" target="_blank"  class="btn btn-xs btn-success">预览</a>
														<a  href="{$list.url}"  class="btn btn-xs btn-success" download="{$list.original_name}">下载</a>
													</td>
													</td>
												</tr>
												</volist>
											</tbody>
											 <tfoot class="footer-menu">
												<tr>
												  <td colspan="12">
													<nav class="text-right">
													  <ul class="pagination hide-if-no-paging"></ul>
													</nav>
												  </td>
												</tr>
											  </tfoot>

										</table>
            </div>
          </div>
		      
      </div>

		
</block>
<block name="Script">
	
  <!-- FooTable Plugin -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.all.min.js"></script>
   <!-- FooTable Addon -->
  <script src="__ABSOLUTEADMIN__/vendor/plugins/footable/js/footable.filter.min.js"></script>
  
 <script type="text/javascript">
 
	
		function unSelect(){
				
		  $("input[id='batch']").each(function(){
		   $(this).prop("checked",false);
		  });  
		  
	
		}
		
		function delete_file(id){
			layer.confirm('你确定要这样做么？', {
				  btn: ['确定','取消'] //按钮
				}, function(){
				  
				  $.ajax({
						type:'POST',
						url:"__APP__/Mall/Classify/delete_file.html",
						data:{
							"id": id,
						},
						success:function(info){
								if (info == 1) {
									layer.msg("删除成功");
									setTimeout(window.location.reload(),3000);
								}else{
									layer.msg("删除失败");
								}
						},
						error:function(){
							layer.msg('系统繁忙,请稍候重试！');
						}
					
					});	 
				  
			}, function(){
			  
			  
			});
		}
		
		function employ(form_id,type,id){
			layer.confirm('你确定要这样做么？', {
				  btn: ['确定','取消'] //按钮
				}, function(){
				  
				  $.ajax({
						type:'POST',
						url:"__APP__/Mall/Classify/employ.html",
						data:{
							"form_id": form_id,
							"type": type,
							"id": id,
						},
						success:function(info){
								if (info == 1) {
									layer.msg("修改成功");
									setTimeout(window.location.reload(),3000);
								}else{
									layer.msg("修改失败");
								}
						},
						error:function(){
							layer.msg('系统繁忙,请稍候重试！');
						}
					
					});	 
				  
			}, function(){
			  
			  
			});
		}
		
		function selectAll(){
				
		 $("input[id='batch']").each(function(){
		   $(this).prop("checked",true);
		  });  
		  
		}
		
		function reverse(){
				
		 $("input[id='batch']").each(function(){
			$(this).prop("checked",!this.checked);   
		  
			})
		}
		
		function status(status){
				
				
						 var id=$('input[id="batch"]:checked').map(function(){return this.value}).get().join();
						
						layer.confirm('你确定要这样做么？', {
						  btn: ['确定','取消'] //按钮
						}, function(){
						  
						  $.ajax({
								type:'POST',
								url:"__APP__/Admin/Behavior/Delete.html",
								data:{
									
									"id": id,
									"status": status,
									
								},
								success:function(data){			
										var info = eval(data)
										if (info.errcode == 0) {
										
											layer.msg(info.errmsg);
											setTimeout(window.location.reload(),3000);
											
										}else{
											layer.msg(info.errmsg);
										}
								},
								error:function(){
									layer.msg('系统繁忙,请稍候重试！');
								}
							
							});	 
						  
						}, function(){
						  
						  
						});

					
				
				}
				
		  </script>
 <script type="text/javascript">
  jQuery(document).ready(function() {

 

    // Init FooTable Examples
    $('.footable').footable();


  });
  </script>
</block>